package com.jtpay.sdk.view;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.jtpay.sdk.R;
import com.jtpay.sdk.adapter.RecycleViewAdapter;
import com.jtpay.sdk.model.PlatformInfo;
import com.jtpay.sdk.util.JftConstants;
import com.jtpay.sdk.util.JftLogUtil;

import java.util.ArrayList;

/**
 * Created by Administrator on 2016/6/18 0018.
 */

public class RecycleViewFragment extends Fragment {
    private static final String TAG = RecycleViewFragment.class.getName();
    protected RecyclerView mRecyclerView;
    protected RecycleViewAdapter mRecycleViewAdapter;
    protected RecycleViewDivider mRecycleViewDivider;
    private ArrayList<PlatformInfo> mPlatformInfos;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        JftLogUtil.log("RecycleViewFragment onCreate");
        super.onCreate(savedInstanceState);
        Bundle bundle = getArguments();
        mPlatformInfos = bundle.getParcelableArrayList(JftConstants.JUN_FU_TONG_PLAT_FORM_KEY);

    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        JftLogUtil.log("RecycleViewFragment onCreateView");
        View root_view = inflater.inflate(R.layout.fragment_platform, container, false);
//        Toolbar toolbar = (Toolbar) root_view.findViewById(R.id.toolbar);
//        toolbar.inflateMenu(R.menu.settings);
//        toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
//            @Override
//            public boolean onMenuItemClick(MenuItem item) {
//                if (R.id.setting == item.getItemId()) {
//                    launchSettings();
//                }
//                return true;
//            }
//        });
        root_view.setTag(TAG);
        mRecyclerView = (RecyclerView) root_view.findViewById(R.id.recycler_view);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
        mRecycleViewAdapter = new RecycleViewAdapter(mPlatformInfos);
        mRecycleViewDivider = new RecycleViewDivider(getContext());
        mRecyclerView.addItemDecoration(mRecycleViewDivider);
        mRecyclerView.setAdapter(mRecycleViewAdapter);
        return root_view;
    }

//    private void launchSettings() {
//        Intent intent = new Intent();
//        intent.setClass(getContext(), SettingActivity.class);
//        startActivity(intent);
//    }

}
